<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>delay</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="dconv.html" title="dconv" />
    <link rel="next" href="delay1.html" title="delay1" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">delay</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="dconv.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="delay1.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="delay"></a>
      <div class="titlepage"></div>
      <a id="IndexDelay" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">delay</span>
        </h2>
        <p>delay — 
      Delays an input signal by some time interval.
          </p>
      </div>
      <div class="refsect1">
        <a id="idp98091888"></a>
        <h2>Description</h2>
        <p>
      A signal can be read from or written into a delay path, or it can be automatically delayed by some time interval.
   </p>
      </div>
      <div class="refsect1">
        <a id="idp98093376"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>delay</strong></span> asig, idlt [, iskip]</pre>
      </div>
      <div class="refsect1">
        <a id="idp98095616"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>idlt</em></span> -- requested delay time in seconds. This can be as large as available memory will permit. The space required for n seconds of delay is 4n * <span class="emphasis"><em>sr</em></span> bytes. It is allocated at the time the instrument is first initialized, and returned to the pool at the end of a score section.
    </p>
        <p>
      <span class="emphasis"><em>iskip</em></span> (optional, default=0) -- initial disposition of delay-loop data space (see <a class="link" href="reson.html" title="reson"><em class="citetitle">reson</em></a>). The default value is 0.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp98166208"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>asig</em></span> -- audio signal
    </p>
        <p>
      <span class="emphasis"><em>delay</em></span> is a composite of <a class="link" href="delayr.html" title="delayr"><em class="citetitle">delayr</em></a> and <a class="link" href="delayw.html" title="delayw"><em class="citetitle">delayw</em></a>, both reading from and writing into its own storage area. It can thus accomplish signal time-shift, although modified feedback is not possible. There is no minimum delay period.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp98171040"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the delay opcode. It uses the file <a class="ulink" href="examples/delay.csd" target="_top"><em class="citetitle">delay.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp98172816"></a>
          <p class="title">
            <strong>Example 175. Example of the delay opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac     <span class="comment">;;;RT audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if RT audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o delay.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span>     <span class="op">=</span> 44100
<span class="ohdr">ksmps</span>  <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

<span class="oblock">instr</span>    1

adel	<span class="opc">init</span> 0
ilev    <span class="op">=</span> p4				<span class="comment">;level of direct sound</span>
idelay  <span class="op">=</span> p5 <span class="op">*</span>.001			<span class="comment">;Delay in ms</span>
ifd	<span class="op">=</span> p6				<span class="comment">;feedback</span>

ain	<span class="opc">diskin2</span> "fox.wav", 1, 1
adel	<span class="opc">delay</span>   ain <span class="op">+</span> (adel<span class="op">*</span>ifd), idelay<span class="comment">;ifd = amount of feedback</span>
asig	<span class="opc">moogvcf</span>	adel, 1500, .6, 1	<span class="comment">;color feedback</span>
	<span class="opc">outs</span>    asig<span class="op">*</span>ilev, ain

<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="comment">;Delay is in ms</span>
<span class="stamnt">i</span> 1  0  15 2  200 .95	<span class="comment">;with feedback</span>
<span class="stamnt">i</span> 1  4  5  2  20  .95
<span class="stamnt">i</span> 1  +  3  2  5   .95
<span class="stamnt">i</span> 1  +  3  3  5   0	<span class="comment">;no feedback</span>

<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp98177136"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="delay1.html" title="delay1"><em class="citetitle">delay1</em></a>, 
      <a class="link" href="delayr.html" title="delayr"><em class="citetitle">delayr</em></a>, 
      <a class="link" href="delayw.html" title="delayw"><em class="citetitle">delayw</em></a>
    </p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="dconv.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="delay1.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">dconv </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> delay1</td>
        </tr>
      </table>
    </div>
  </body>
</html>
